<template>
  <div class="box4" ref="map"></div>
</template>

<script setup lang="ts" name="Map">
import { ref, onMounted } from 'vue'
import * as echarts from 'echarts'
import ChinaJSON from './china.json'
//获取DOM元素
let map = ref()
//注册中国地图
echarts.registerMap('china', ChinaJSON as any)
onMounted(() => {
  let mychart = echarts.init(map.value)
  //设置配置项
  mychart.setOption({
    geo: {
      map: 'china', //中国地图
      roam: true, //鼠标缩放的效果
      //地图各省文字的展示
      label: {
        show: true,
        color: 'white',
        fontSize: 13,
      },
      //每一个多边形的样式
      itemStyle: {
        color: 'skyblue',
        opacity: 0.8,
      },
      //地图高亮的效果
      emphasis: {
        itemStyle: {
          color: 'pink',
        },
        label: {
          fontSize: 20,
        },
      },
    },
    //布局位置
    grid: {
      left: 100,
      top: 0,
      right: 0,
      bottom: 0,
    },
    series: [
      {
        type: 'lines', //航线的系列
        data: [
          {
            coords: [
              [116.405285, 39.904989], //起点
              [108.320004, 22.82402], //终点
            ],

            //统一的样式设置
            lineStyle: {
              color: 'white',
              width: 6,
            },
          },
          {
            coords: [
              [87.617733, 43.792818], //起点
              [114.173355, 22.320048], //终点
            ],

            //统一的样式设置
            lineStyle: {
              color: 'white',
              width: 6,
            },
          },
          {
            coords: [
              [112.982279, 28.19409], //起点
              [91.132212, 29.660361], //终点
            ],

            //统一的样式设置
            lineStyle: {
              color: 'white',
              width: 6,
            },
          },
        ],
        //开启动画特效
        effect: {
          show: true,
          symbol: 'arrow',
          color: 'yellow',
          symbolSize: 15,
        },
      },
    ],
  })
})
</script>

<style scoped lang="scss">

</style>
